<?php

class eventlist
{
public function index()
{
$page = intval($GLOBALS['request']['page']);
if($page==0)
$page = 1;
$cate_id = intval($GLOBALS['request']['cate_id']);
$city_id = intval($GLOBALS['request']['city_id']);
$ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']);
$ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']);
$xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']);
$xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']);
$ypoint =  $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
$xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
if($xpoint>0)
{
$pi = 3.14159265;
$r = 6378137;
$field_append = ", (ACOS(SIN(($ypoint * $pi) / 180 ) *SIN((ypoint * $pi) / 180 ) +COS(($ypoint * $pi) / 180 ) * COS((ypoint * $pi) / 180 ) *COS(($xpoint * $pi) / 180 - (xpoint * $pi) / 180 ) ) * $r) as distance ";
$where = " ypoint > $ybottom and ypoint < $ytop and xpoint > $xleft and xpoint < $xright ";
$order = ' distance asc ';
}
else
{
$field_append = $where = $order = '';
}
$limit = (($page-1)*PAGE_SIZE).','.PAGE_SIZE;
$res = m_search_event_list($limit,$cate_id,$city_id,$where,$order,$field_append);
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]['distance'] = round($v['distance']);
$res['list'][$k]['date_time'] = pass_date($v['submit_begin_time']);
}
$root = array();
$root['return'] = 1;
$root['item'] = $res['list'];
$root['page'] = array('page'=>$page,'page_total'=>ceil($res['count']/PAGE_SIZE));
output($root);
}
}

?>